package com.huzz.util.desin.abstractfactory;


import com.huzz.util.desin.abstractfactory.product.CoffeeBean;
import com.huzz.util.desin.abstractfactory.product.MilkFoam;

public class CoffeeMaker {
    private CoffeeFactory factory;

    public CoffeeMaker(CoffeeFactory factory) {
        this.factory = factory;
    }

    public void makeCoffee() {
        CoffeeBean coffeeBean = factory.createCoffeeBean();
        MilkFoam milkFoam = factory.createMilkFoam();

        coffeeBean.grind();
        milkFoam.froth();

        System.out.println("Enjoy your coffee!");
    }

    public static void main(String[] args) {
        // 使用意式咖啡机制作咖啡
        CoffeeFactory espressoFactory = new EspressoMachineFactory();
        CoffeeMaker espressoCoffeeMaker = new CoffeeMaker(espressoFactory);
        espressoCoffeeMaker.makeCoffee();

        System.out.println();

        // 使用美式咖啡机制作咖啡
        CoffeeFactory americanoFactory = new AmericanoMachineFactory();
        CoffeeMaker americanoCoffeeMaker = new CoffeeMaker(americanoFactory);
        americanoCoffeeMaker.makeCoffee();
    }
}
